<?php
$front = Zend_Controller_Front::getInstance()->getRequest();
$action = "/" . $front->getModuleName() . "/" . $front->getControllerName() ;
?>
<script type="text/javascript" >
function confirmDelete( id, locked ) {
    var accion = 'eliminar';
    if( locked == 'T' ) {
        accion = 'recuperar';
    }
	Sexy.confirm('Esta segur@ que quiere ' + accion + ' este registro?', {onComplete:
		function(returnvalue) {
            if(returnvalue) {
              	Sexy.info('Registro eliminado con exito');
              	location.href= "<?=$action?>/delete/id/" + id;
            } else{
            	return false;
        	}
    	}
	});
}
</script>

<h1>Roles</h1>

<a class="button" href="/roles/create/" title="Agregar un role nuevo">
        <span >Agregar un Role <img src="/imgs/plus.gif" width="9px" alt="plus" /></span>
    </a>
    <br/>
    <br/>
<div class="module">

<?php if (count($this->paginator)): ?>
    <?php echo $this->paginator ?>
    <div class="module-table-body">
        <table id="myTable" class="tablesorter">
            <thead>
                <tr>
                    <th class="header">Id</th>
                    <th class="header">Nombre</th>
                    <th class="header">&nbsp;</th>
                </tr>
            </thead>
			<tbody>
				<? $i=0; foreach ($this->paginator as $node) : ?>
				<tr class=<?php echo ($i%2==0?'"even"':'"odd"') ?>>
					<td><?=$node['id'] ?></td>
					<td><a href="/acl/list/role/<?=$node['id'] ?>/" ><?=$node['name'] ?></a></td>

					<td>

						<ul id="icons" class="ui-widget ui-helper-clearfix">
							<li class="ui-state-default ui-corner-all">
								<a onclick="confirmDelete( <?=$node['id']?>,  '<?=$node['locked'] ?>');return false;" title="Borrar a <?=$node['name'] ?>" class="tooltip" href="#">
									<span class="ui-icon ui-icon-circle-close"></span>
								</a>
							</li>

							<li class="ui-state-default ui-corner-all">
								<a title="Editar a <?=$node['name'] ?> " class="tooltip" href="/roles/update/id/<?=$node['id']?>/">
									<span class="ui-icon ui-icon-pencil"></span>
								</a>
							</li>
						</ul>
					</td>
				</tr>
				<?php $i++;  endforeach;?>

			</tbody>
		</table>
	</div>
    <?php echo $this->paginator ?>
<?php endif;?>
</div> <!-- End .module -->